<?php
/**
 * 公共模型
 * Created by PhpStorm.
 * User: 武 斌
 * Date: 2016/12/14
 * Time: 16:21
 */

namespace Common\Model;


use Think\Model;

class BaseModel extends Model
{
	public function store($data)
    {
        if ($this->create($data)) {
            //验证成功
            //print_r($this->pk);die;
            $action = isset($data[$this->pk]) ? 'save' : 'add';
            //echo $action;
            $res = $this->$action($data);
            return ['status' => 'success', 'message' => '操作成功', 'data' => $res];
        } else {
            //验证失败
            return ['status' => 'failed', 'message' => $this->getError()];
        }
    }
}